﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Windows.Controls;

namespace WPFIPodControls
{
    /// <summary>
    /// Converter to get currentIndex of an object, it used to hide bottom line after the last object in listbox
    /// </summary>
    class IndexToVisibilityConverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            object lbi = values[0];
            ItemsControl ctls = values[1] as ItemsControl;
            if (ctls != null)
            {
                int i = ctls.Items.IndexOf(lbi);
                if (i == ctls.Items.Count - 1)
                    return Visibility.Collapsed;
            }
            return Visibility.Visible;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
